/*
 *@功能: 小组动态item
 *@author: lovecrosszhu
 *@date: 2021-02-02 16:49:04
 *@version: V1.0.0
*/

import 'package:color_dart/RgbaColor.dart';
import 'package:flutter/material.dart';
import 'package:im_flutter_sdk_example/jsonserialize/moment/data.dart';
import 'package:im_flutter_sdk_example/pages/photoview/fade_route.dart';
import 'package:im_flutter_sdk_example/pages/photoview/index.dart';
import 'package:im_flutter_sdk_example/utils/global.dart';
import 'package:im_flutter_sdk_example/utils/screen.dart';

class MomentItemMultiPic extends StatelessWidget {
  final MomentItem item;
  const MomentItemMultiPic({Key key, this.item}) : super(key: key);

  Widget _buildImage(String path) {
    return Image.network(
      // path,
      G.thumbImage112_80(path),
      width: 220.w,
      height: 220.w,
      fit: BoxFit.cover,
    );
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.fromLTRB(0, 10, 0, 10),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Container(
            margin: EdgeInsets.only(bottom: 24.h),
            child: Text(
              '${item.content}',
              maxLines: 2,
              overflow: TextOverflow.ellipsis,
              style: TextStyle(
                  color: rgba(51, 51, 51, 1),
                  fontSize: 16,
                  fontWeight: FontWeight.w500),
            ),
          ),
          Wrap(
            spacing: 6.0,
            runSpacing: 8.0,
            children: [
              ...item.pictures
                  .map((picUrl) => InkWell(
                        onTap: () {
                          //FadeRoute是自定义的切换过度动画（渐隐渐现） 如果不需要 可以使用默认的MaterialPageRoute
                          Navigator.of(context).push(new FadeRoute(
                              page: PhotoViewGalleryScreen(
                            images: item.pictures, //传入图片list
                            index: 0, //传入当前点击的图片的index
                            // heroTag: "$picUrl", //传入当前点击的图片的hero tag （可选）
                          )));
                        },
                        child: _buildImage(picUrl),
                      ))
                  .toList()
            ],
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Text(
                '${item.createdTime}',
                style: TextStyle(color: rgba(191, 191, 191, 1), fontSize: 12),
              ),
              Text(
                '${item.likes}评论',
                style: TextStyle(color: rgba(191, 191, 191, 1), fontSize: 12),
              ),
            ],
          )
        ],
      ),
    );
  }
}
